<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/15 0015
 * Time: 10:10
 */

namespace Cohuna\Models;
use Phalcon\Di;

/**
 * 商户表
 * @package Cohuna\Models
 */
class CohunaMerchant extends ModelBase
{
    public $id;
    public $merchant_id;
    public $merchant_name;
    public $merchant_status;
    public $merchant_image_url;
    public $gateway;
    public $merchant_public_cert;
    public $is_delete;
    public $remark;
    public $create_time;
    public $create_id;
    public $update_time;
    public $update_id;

    public function getSource()
    {
        return Di::getDefault()->getShared('config')->database->default->prefix . 'merchant';
    }
    public function beforeUpdate()
    {
        $this->update_time = date('Y-m-d H:i:s');
    }
    public function beforeCreate()
    {
        $this->create_time = date('Y-m-d H:i:s');
        $this->is_delete = 0;
    }

    public static function createMerchantId()
    {
        $id = md5(uniqid('MerchantId',true));
        return substr($id,8,16);
    }
}